package basic_1018;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner=new Scanner(System.in);
		
		int N=scanner.nextInt();
		
		Map<Integer, Integer>grades=new HashMap<Integer, Integer>();
		
		for(int i=0;i<N;i++) {
			int grade=scanner.nextInt();
			if(grades.containsKey(grade)) {
				grades.put(grade, grades.get(grade)+1);
			}else {
				grades.put(grade, 1);
			}
		}
		
		int K=scanner.nextInt();
		int[] Search=new int[K];
		
		for(int i=0;i<K;i++) {
			Search[i]=scanner.nextInt();
		}
		
		scanner.close();
		StringBuffer buffer=new StringBuffer();
		for(int search:Search) {
			int grade=grades.containsKey(search)?grades.get(search):0;
			buffer.append(grade);
			buffer.append(" ");
		}
		System.out.println(buffer.toString().trim());
	}
}
